//
//  mAppointmentHouseView.m
//  YIJU2.0HD
//
//  Created by URANUS on 16/5/23.
//  Copyright © 2016年 Mr.X. All rights reserved.
//

/**
 预约看房PopOver
 */

#import "mAppointmentHouseView.h"
#import "Masonry.h"
#import "Macro.h"
#import "mAppointmentTableViewCell.h"
#import "mAppointmentModel.h"

@interface mAppointmentHouseView ()<UITableViewDataSource,UITableViewDelegate>
@property (nonatomic, strong) UITableView *MessageTableView;

@property (nonatomic, strong)NSMutableArray *model;//数据模型数组

@end

@implementation mAppointmentHouseView
- (instancetype)init {
    if (self = [super init]) {
        [self setUpContaints];
    }
    return self;
}

- (void)setUpContaints {
    mAppointmentModel *tempModel = [mAppointmentModel new];
    tempModel.HouseCode = @"10栋2单元17楼3号";
    tempModel.name = @"张金国";
    tempModel.date = @"2016-03-31";
    tempModel.phoneNum = @"15520791315";
    tempModel.peopleNum = @"100";
    tempModel.comments = @"";
    
    [self.model addObject:tempModel];
    [self.MessageTableView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.equalTo(self);
    }];
}

#pragma mark - Delegate
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return self.model.count;
}

- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section {
    UIView *view = [UIView new];
    return view;
}

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section {
    return 0.1;
}

- (UIView *)tableView:(UITableView *)tableView viewForFooterInSection:(NSInteger)section {
    UIView *view = [UIView new];
    return view;
}

- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section{
    return 0.1;
}

- (CGFloat)tableView:(UITableView *)tableView estimatedHeightForRowAtIndexPath:(NSIndexPath *)indexPath {

    return 80;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    id<CustomCellModel> cellModel = [self.model objectAtIndex:indexPath.row];
    UITableViewCell *cell = [UITableViewCell tableView:tableView cellWithModel:cellModel];
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    return cell;
}

#pragma mark - getter
- (NSMutableArray *)model {
    if (!_model) {
        _model = [NSMutableArray array];
    }
    return _model;
}

- (UITableView *)MessageTableView {
    if (!_MessageTableView) {
        _MessageTableView = [[UITableView alloc]initWithFrame:CGRectZero style:UITableViewStyleGrouped];
        _MessageTableView.rowHeight = UITableViewAutomaticDimension;
        _MessageTableView.estimatedRowHeight = 100;
        _MessageTableView.delegate = self;
        _MessageTableView.dataSource = self;
        _MessageTableView.separatorStyle = UITableViewCellSeparatorStyleNone;
        [self addSubview:_MessageTableView];
        }
    return _MessageTableView;
}

@end
